package com.xxxx.server.controller;


import com.xxxx.server.pojo.Position;
import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.service.IPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhoubin
 */
@RestController
@RequestMapping("/system/basic/pos")
public class PositionController {

    @Autowired
    private IPositionService iPositionService;


    @GetMapping("/")
    public List<Position> selectPosition(String name){
        List<Position> list=iPositionService.selectPositionservice(name);
        return list;
    }

    @PostMapping("/")
    public RespBean addPosition(@RequestBody Position positionvo){

        return iPositionService.addPositionservice(positionvo);
    }


    @PutMapping("/")
    public RespBean upPosition(@RequestBody Position positionvo){
        System.out.println(positionvo);
        return iPositionService.updatePositionservice(positionvo);


    }

    @DeleteMapping("/{id}")
    public RespBean deletPosition(@PathVariable String id){
        System.out.println(id);
        return  iPositionService.deletPositionservice(id);

    }

    @DeleteMapping("/")
    public RespBean deletJoblevel(String[] ids){
        System.out.println(ids);

        if(iPositionService.removeByIds(Arrays.asList(ids))){

            return RespBean.success("删除成功！");
        }
        return RespBean.error("删除失败！");

    }
}
